package org.client.otdr.resolver;

import org.client.otdr.OTDRID;
import org.openems.entity.Entity;
import org.openems.entity.TraceEntity;

import framework.AccessorHelper;
import framework.UtilityUnit;
import framework.resolver.UnitResolver;

public class IorResolver implements UnitResolver {

	@Override
	public void resolve(Entity oldEntity, Entity newEntity, AccessorHelper helper) {
		OTDRID id = OTDRID.get();
		Double ior = helper.getDoubleValue(id.IOR);
		TraceEntity trace = (TraceEntity)helper.getAccessor().get(id.TRACE);
		trace.setHorizontalMax(helper.getDoubleValue(id.ACTIVETRACERANGE) * ior /1.5);
		helper.getAccessor().put(trace);

		Double rangeIOR = UtilityUnit.toDouble(helper.getSelectedItem(id.DISTANCERANGE)) * ior / 1.5;
		helper.setDoubleValue(id.ACTIVETRACERANGEIOR, rangeIOR);
	}

}
